home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////
- // This example code is from the book:
- //
- // Object-Oriented Programming with C++ and OSF/Motif
- // by
- // Douglas Young
- // Prentice Hall, 1992
- // ISBN 0-13-630252-1
- //
- // Copyright 1991 by Prentice Hall
- // All Rights Reserved
- //
- // Permission to use, copy, modify, and distribute this software for
- // any purpose except publication and without fee is hereby granted, provided
- // that the above copyright notice appear in all copies of the software.
- ///////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////
-
-
- ////////////////////////////////////////////////////////////////
- // Stopwatch.h: Group subcomponents into one stopwatch component
- ////////////////////////////////////////////////////////////////
- #ifndef STOPWATCH_H
- #define STOPWATCH_H
- #include "UIComponent.h"
- #include "Timer.h"
-
- // Header file doesn't need the full declaration of these classes
-
- class Face;
- class Control;
-
- class Stopwatch : public UIComponent {
-
- friend Control; // Let Control call protected Stopwatch functions
-
- private:
-
- // Encapsulate a resource specification used to init this class
-
- static XtResource _resources[];
-
- Face *_face; // The display of the stopwatch
- Timer *_timer; // The object that keeps the time
- Control *_control; // Control panel that starts and stops timing
-
- protected:
-
- virtual void timerStarted(); // Subclass hooks called when
- virtual void timerStopped(); // timer starts and stops
- float elapsedTime() { return _timer->elapsedTime(); }
- int _interval;
-
- public:
-
- Stopwatch ( Widget, char * );
- virtual ~Stopwatch();
- virtual const char *const className() { return "Stopwatch"; }
- };
- #endif
-